﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using yiCommerce.Core;
using yiCommerce.Service.Messages;
using yiCommerce.Service.Statuses;

namespace yiCommerce.Controllers.api
{
    public class CommentsApiController : ApiController
    {
        private ICommentService _commentService;

        private IWorkContext _workContext;
        private IMessageService _messageService;

        public CommentsApiController(ICommentService commentService, IWorkContext workContext, IMessageService messageService)
        {
            _commentService = commentService;
            _workContext = workContext;
            _messageService = messageService;
        }

        public AddCommentsResult AddComments(AddCommentsRequest request)
        {
            var result = new AddCommentsResult();
            try
            {

                _commentService.AddComment(request.StatusId, _workContext.CurrentCustomer.Id, request.Text);
                result.Status = ConstInfo.ResultSuccessStatus;
                result.Message = _messageService.GetResourceValue(Messages.CommentsAddSuccessfully, 0);
            }
            catch (Exception e)
            {
                result.Status = ConstInfo.ResultFailedStatus;
                result.Message = e.Message;

            }
            return result;
        }
    }

    public class AddCommentsRequest
    {
        public int StatusId { get; set; }
        public string Text { get; set; }

    }
}

    public class AddCommentsResult
    {
        public string Status { get; set; }
        public string Message { get; set; }
    }
